import Request from "@/utils/request";
import qs from "qs";

/* 订单相关 */
// 优惠券
export const getCoupons = (data) =>
  Request.request("POST", "/api/coupons/getCoupons", data).then(
    (res) => res.data
  );

// 获取订单列表
export const getOrderList = (data) => {
  return Request.request(
    "GET",
    `/alipay/order/myList?${qs.stringify(data)}`,
    data
  ).then((res) => res.data);
};

// 创建订单
export const createOrder = (data) =>
  Request.request("POST", "/alipay/order/createOrder", data).then(
    (res) => res.data
  );


  // 取消订单
  export const cancelOrder = (id) =>
  Request.request("GET", `/alipay/order/cancel?id=${id}`).then(
    (res) => res.data
  );

// 预支付
export const prePay = (id) =>
  Request.request("POST", '/alipay/pay/prePay', { id: id }).then(
    (res) => res.data
  );

// 获取信息详情
export const getDetail = (orderId) => {
  return Request.request("GET", `/report/getReport?orderId=${orderId}`).then(res => res.data).catch(e => {
    console.log('捕获错误', e)
  })
}